package com.yfp.client.service.impl;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yfp.client.domain.OrderCombo;
import com.yfp.client.domain.dto.OrderListDTO;
import com.yfp.client.mapper.OrderComboMapper;
import com.yfp.client.service.OrderComboService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author admin
 * @description 针对表【order_combo】的数据库操作Service实现
 * @createDate 2024-05-24 11:28:52
 */
@Service
public class OrderComboServiceImpl extends ServiceImpl<OrderComboMapper, OrderCombo> implements OrderComboService {

    @Resource
    private OrderComboMapper orderComboMapper;

    @Override
    public List<String> getOrderIdList(OrderCombo orderCombo) {
        return orderComboMapper.getOrderIdList(orderCombo);
    }

    @Override
    public List<OrderCombo> getLimitOrder(OrderListDTO orderListDTO) {
        return orderComboMapper.getLimitOrder(orderListDTO);
    }

    /**
     * 根据用户id查询订单
     *
     * @param userId
     * @return
     */
    @Override
    public List<OrderCombo> listByUserIdAndStatus(OrderListDTO userId) {
        return orderComboMapper.listByUserIdAndStatus(userId);
    }

    /**
     * 根据订单id更新存柜状态
     *
     * @param orderId
     * @return
     */
    @Override
    public void updateCupboardState(String orderId) {
        orderComboMapper.updateCupboardState(orderId, 1);
    }

    @Override
    public Integer countOrderByClientId(String clientId) {
        return orderComboMapper.countOrderByClientId(clientId);
    }

    @Override
    public String countMachineId(String clientId) {
        return orderComboMapper.countMachineId(clientId);
    }

    @Override
    public OrderCombo listLastByClientId(String clientId, List<String> statusList) {
        return orderComboMapper.listLastByClientId(clientId, statusList);
    }

    @Override
    public Integer countOrderByClientIdAndCreateTime(String clientId, DateTime date) {
        return orderComboMapper.countOrderByClientIdAndCreateTime(clientId, date);
    }

    @Override
    public Boolean isFirstOrder(String clientId) {
        return orderComboMapper.isFirstOrder(clientId) == 0;
    }

    /**
     * 根据用户id获取最后一单订单号
     * @param clientId
     * @return
     */
    @Override
    public String getByUserId(String clientId) {
        return orderComboMapper.getByUserId(clientId);
    }

}




